% same as main.m/main_sandbox.m baseline camera code
function [XTR,YTR,XTE,YTE,XTV,YTV,ANN_TR,ANN_TE,ANN_TV] = grabSourceData(name, holdout_cam)
	
	% addpath('../webcam-classifier-toolbox');

	prefix = 'data/';
	basedata = {};
	
	if strcmp(name, 'ITER_DATA')
		disp('iter');
		basedata.save = 'iter';
		basedata.type = 'ITER_DATA';
		basedata.file = [prefix 'iter_data2.mat'];
	elseif strcmp(name, 'SPECIAL_ITER')
		disp('special');
		basedata.save = 'special_iter';
		basedata.type = 'SPECIAL_ITER';
		basedata.file = [prefix 'special_iter_data2.mat'];		
	elseif strcmp(name, 'SANDBOX_RUN1')
		disp('sandbox_run1');
		basedata.save = 'sandbox1';
		basedata.type = 'SANDBOX_RUN1';
		basedata.file = [prefix 'sandbox1_data2.mat'];
	elseif strcmp(name, 'SR1_ITER_IMPROVED')
		disp('sr1_iter_improved');
		basedata.save = 'sr1_iter_improved';
		basedata.type = 'SR1_ITER_IMPROVED';
		basedata.file = [prefix 'sr1_iter_improved_model.mat'];
	elseif strcmp(name, 'SR1_ITER_IMPROVED_V2')
		disp('s1_iter_improved_v2');
		basedata.save = 'sr1_iter_improved_v2';
		basedata.type = 'SR1_ITER_IMPROVED_V2';
		basedata.file = [prefix 'sr1_iter_improved_v2_model.mat'];
	else
		basedata.type = name;
	end
	
	disp('Loading...');
	% if ~exist(basedata.file,'file')
		disp('Data does not exist, must grab it');
		dataset = getData(basedata.type);
		num_cams = size(dataset,1);
% 
% 		if strcmp(name, 'SANDBOX_RUN1')
			rest = setdiff(1:num_cams, holdout_cam); % remove new camera 4
			dataset = dataset(rest,:);
			num_cams = num_cams-length(holdout_cam);
% 		elseif strcmp(name, 'ITER_DATA')
% 			rest = setdiff(1:num_cams, 5); % remove new camera 5
% 			dataset = dataset(rest,:);
% 			num_cams = num_cams-1;
% 		end
		
		[test_prefs test_sets test_anns train_prefs train_sets train_anns valid_prefs valid_sets valid_anns] = splitDataTTV(dataset);
		
		XTR = [];
		YTR = [];
		XTE = [];
		YTE = [];
		XTV = [];
		YTV = [];
		ANN_TR = [];
		ANN_TV = [];
		ANN_TE = [];
		for i = 1:num_cams
			XTR = [XTR; double(train_sets{i})];
			YTR = [YTR; double(train_prefs{i})];
			XTE = [XTE; double(test_sets{i})];
			YTE = [YTE; double(test_prefs{i})];
			XTV = [XTV; double(valid_sets{i})];
			YTV = [YTV; double(valid_prefs{i})];
			ANN_TR = [ANN_TR train_anns{i}];
			ANN_TV = [ANN_TV valid_anns{i}];
			ANN_TE = [ANN_TE test_anns{i}];
		end
		% keyboard
		% save(basedata.file,'XTR','YTR','XTE','YTE','XTV','YTV','ANN_TR','ANN_TE','ANN_TV','dataset');	
	% else
	% 	disp('Data premade!');
	% 	load(basedata.file);
	% end
end
